
#ifndef SX_QVIEWPORT_FRAME_LAYOUT_H
#define SX_QVIEWPORT_FRAME_LAYOUT_H

#include <QWidget>
#include <sxArrayList.h>
#include <sxQViewportFrame.h>

namespace Sx {
namespace QtInterface {

class QViewportFrameLayout : public QWidget {
	Q_OBJECT

public:
	QViewportFrameLayout(QWidget* parent = nullptr);
	virtual ~QViewportFrameLayout();

	/*
	 * This layout is still abstract and only provides a list of QViewportFrames
	 * for concrete subclasses. This function must be implemented to return the
	 * correct number of viewport frames the layout will hold upon 
	 * initialization.
	 */
	virtual unsigned int getRequiredViewportCount() const = 0;

	/* Provide an array of initialized ViewportFrames to fill the Layout */
	virtual bool setViewportFrames(const Util::ArrayList<QViewportFrame*>& viewports) = 0;

	/* Maximizes the selected viewport. See the slot: onFocusViewportChange. */
	bool maximizeSelectedViewport(bool maximize);
	void deselectAllViewports();

public slots:
	/*
	 * This slot is provided for each viewport in any layout that extends this
	 * class. When the focus is changed from one viewport to another in a
	 * layout this slot changes the selected viewport which can be referenced
	 * as the selected viewport.
	 */
	void onFocusedViewportChange(QViewportFrame* viewport);

protected:
	/* POINTER_OWNERSHIP: NO (Qt Handles QWidgets) */
	Util::ArrayList<QViewportFrame*> viewportFrames;

	/* POINTER_OWNERSHIP: NO (Qt Handles QWidgets) */
	QViewportFrame* focusedViewport;
};

}

}

#endif
